<template>
	<div class="app-container">
		<el-container style="display:flex">
			<!-- 			<el-aside width="250px">
				<el-tree :default-expanded-keys="expandNodes" :props="props" :load="loadNode" lazy
					@node-click="handleClick">
				</el-tree>
			</el-aside> -->
			<el-main>
				<div>
					<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
						label-width="68px">
						<el-form-item label="学校">
							<el-select v-model="queryParams.schoolid" placeholder="请选择学校" clearable
								@change="changeSchoolNew">
								<el-option v-for="item in schools" :label="item.schoolname" :key="item.schoolname"
									:value="item.schoolid">
								</el-option>
							</el-select>
						</el-form-item>
						<el-form-item label="标题" prop="title">
							<el-input v-model="queryParams.title" placeholder="请输入标题名" clearable
								@keyup.enter.native="handleQuery" />
						</el-form-item>
						<el-form-item label="内容" prop="contenttext">
							<el-input v-model="queryParams.contenttext" placeholder="请输入帖子内容" clearable
								@keyup.enter.native="handleQuery" />
						</el-form-item>
						<el-form-item label="类型" prop="contenttype">
							<el-select v-model="queryParams.contenttype" placeholder="请选择帖子类型" clearable>
								<el-option v-for="dict in dict.type.bbs_new_content_type" :key="dict.value"
									:label="dict.label" :value="dict.value">
								</el-option>
							</el-select>
						</el-form-item>
						<el-form-item label="特殊类型" prop="contenttype">
							<el-select v-model="queryParams.isspecial" placeholder="请选择特殊类型" clearable>
								<el-option v-for="dict in dict.type.bbs_content_special" :key="dict.value"
									:label="dict.label" :value="dict.value">
								</el-option>
							</el-select>
						</el-form-item>
						<el-form-item label="可见范围" prop="visiblerange">
							<el-select v-model="queryParams.visiblerange" placeholder="请选择可见范围" clearable>
								<el-option v-for="dict in dict.type.bbs_content_visibleRange" :key="dict.value"
									:label="dict.label" :value="dict.value">
								</el-option>
							</el-select>
						</el-form-item>

						<el-form-item label="状态" prop="contentstate">
							<el-select v-model="queryParams.contentstate" placeholder="请选择帖子状态" clearable>
								<el-option v-for="dict in dict.type.bbs_content_state" :key="dict.value"
									:label="dict.label" :value="dict.value">
								</el-option>
							</el-select>
						</el-form-item>
						<el-form-item label="用户ID" prop="userid">
							<el-input v-model="queryParams.userid" placeholder="请输入用户ID" clearable
								@keyup.enter.native="handleQuery" />
						</el-form-item>
						<el-form-item label="帖子ID" prop="contentid">
							<el-input v-model="queryParams.contentid" placeholder="请输入帖子ID" clearable
								@keyup.enter.native="handleQuery" />
						</el-form-item>
						<el-form-item label="不可评论" prop="nocomment">
							<el-select v-model="queryParams.nocomment" placeholder="是否不可评论" clearable>
								<el-option v-for="dict in dict.type.bbs_true_or_false" :key="dict.value"
									:label="dict.label" :value="dict.value">
								</el-option>
							</el-select>
						</el-form-item>
						<el-form-item label="仅校友可见" prop="alumnionly" label-width="100px">
							<el-select v-model="queryParams.alumnionly" placeholder="是否仅校友可见" clearable>
								<el-option v-for="dict in dict.type.bbs_true_or_false" :key="dict.value"
									:label="dict.label" :value="dict.value">
								</el-option>
							</el-select>
						</el-form-item>
						<el-form-item>
							<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索
							</el-button>
							<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
						</el-form-item>
					</el-form>
					<el-row :gutter="10" class="mb8">
						<right-toolbar :showSearch.sync="showSearch" @queryTable="getContentVoList"></right-toolbar>
					</el-row>
				</div>
				<el-table v-loading="loading" :data="contentList" @selection-change="handleSelectionChange"
					:row-style="{background:'white'}">
					<el-table-column type="selection" width="55" align="center" />
					<el-table-column label="发帖人" align="center">
						<template slot-scope="scope">
							<el-button size="mini" type="text" @click="toUserPage(scope.row)">{{scope.row.nickname}}
							</el-button>
						</template>
					</el-table-column>
					<el-table-column v-if="currentInAllSchool" label="学校" align="center" prop="schoolid" width="120"
						:formatter="formatSchoolName" />
					<!-- <el-table-column label="帖子id" align="center" prop="contentid" :show-overflow-tooltip="true" width="150" /> -->
					<el-table-column label="标题" align="center" prop="title" :show-overflow-tooltip="true" width="150" />
					<el-table-column label="内容" align="center" prop="contenttext" :show-overflow-tooltip="true"
						width="200" />
					<el-table-column label="点赞数" align="center" prop="upnum" width="60" />
					<el-table-column label="评论数" align="center" prop="commentnum" width="60" />
					<el-table-column label="阅读人数" align="center" prop="realreadnum" width="80" />
					<el-table-column label="阅读次数" align="center" prop="readnum" width="80" />
					<el-table-column label="类型" align="center" prop="contenttype">
						<template slot-scope="scope">
							<dict-tag :options="dict.type.bbs_new_content_type" :value="scope.row.contenttype" />
						</template>
					</el-table-column>
					<el-table-column label="特殊类型" align="center" prop="isspecial" width="90">
						<template slot-scope="scope">
							<dict-tag :options="dict.type.bbs_content_special" :value="scope.row.isspecial" />
						</template>
					</el-table-column>
					<el-table-column label="帖子状态" align="center" prop="contentstate">
						<template slot-scope="scope">
							<dict-tag :options="dict.type.bbs_content_state" :value="scope.row.contentstate" />
						</template>
					</el-table-column>
					<el-table-column label="详情" align="center" class-name="small-padding fixed-width">
						<template slot-scope="scope">
							<!-- <el-button size="mini" type="text" icon="el-icon-edit" @click="openModal(scope.row)">查看详情
							</el-button> -->
							<el-button size="mini" type="text" icon="el-icon-edit" @click="openModal2(scope.row)">查看详情
							</el-button>
						</template>
					</el-table-column>
					<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
						<template slot-scope="scope">
							<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">修改
							</el-button>

						</template>
					</el-table-column>
					<el-table-column label="仅校友见" align="center" prop="alumnionly" width="80">
						<template slot-scope="scope">
							<span v-if="scope.row.alumnionly === 1">是</span>
							<span v-else>否</span>
						</template>
					</el-table-column>
					<!-- 					<el-table-column label="联系方式" align="center" prop="place" :show-overflow-tooltip="true"
						width="150" /> -->
					<el-table-column label="创建时间" align="center" prop="createtime" width="180">
						<template slot-scope="scope">
							<span>{{ parseTime(scope.row.createtime) }}</span>
						</template>
					</el-table-column>
					<!-- 					<el-table-column label="更新时间" align="center" prop="updatetime" width="180">
						<template slot-scope="scope">
							<span>{{ parseTime(scope.row.updatetime) }}</span>
						</template> -->
					</el-table-column>
					<el-table-column label="可见范围" align="center" prop="visiblerange">
						<template slot-scope="scope">
							<dict-tag :options="dict.type.bbs_content_visibleRange" :value="scope.row.visiblerange" />
						</template>
					</el-table-column>

				</el-table>
				<pagination v-show="total>0" :total="total" :page.sync="treeQueryParams.pageNum"
					:limit.sync="treeQueryParams.pageSize" @pagination="pageGetVoList0805" />
				<!--          @pagination="getList"-->
				<!--          pageGetList-->
			</el-main>
		</el-container>
		<!-- 添加内容帖对话框 -->
		<el-dialog v-loading="loading" :title="title" :visible.sync="createContentOpen" width="60%" append-to-body>
			<el-form ref="createContentForm" :model="createContentForm" :rules="rules" label-width="150px">
				<el-form-item label="发帖人" prop="userid">
					<el-select v-model="createContentForm.userid" placeholder="请选择发帖人" clearable>
						<el-option v-for="user in robotList" :key="user.userid" :label="user.nickname"
							:value="user.userid">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="帖子所属学校" prop="schoolid">
					<el-select v-model="createContentForm.schoolid" placeholder="请选择学校">
						<el-option v-for="school in currentschools" :key="school.value" :label="school.name"
							:value="school.schoolid">
						</el-option>
					</el-select>
				</el-form-item>
				<!-- <el-form-item label="板块" prop="plateid">
					<el-select v-model="createContentForm.plateid" placeholder="请选择板块" clearable>
						<el-option v-for="plate in currentPlateList" :key="plate.plateid" :label="plate.name"
							:value="plate.plateid">
						</el-option>
					</el-select>
				</el-form-item> -->
				<el-form-item label="标题名" prop="title">
					<el-input v-model="createContentForm.title" placeholder="请输入标题名" />
				</el-form-item>
				<el-form-item label="帖子类型" prop="contenttype">
					<!-- <el-input v-model="createContentForm.contenttype" placeholder="请输入帖子类型。0：普通贴；3:匿名贴；" /> -->
					<el-select v-model="createContentForm.contenttype" placeholder="请选择帖子类型">
						<el-option v-for="contentType in typeList" :key="contentType.value" :label="contentType.name"
							:value="contentType.value">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="特殊选项" prop="isspecial">
					<el-select v-model="createContentForm.isspecial" placeholder="请选择帖子特殊类型" @change="changSpecialKind">
						<el-option v-for="special in specialList" :key="special.value" :label="special.name"
							:value="special.value">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="文字内容" prop="contenttext">
					<el-input type="textarea" v-model="createContentForm.contenttext" :autosize="{ minRows: 5}"
						placeholder="请输入帖子的文字内容" />
				</el-form-item>
				<el-form-item label="上传图片" prop="contenturl"
					v-if="createContentForm.isspecial ==1 || createContentForm.isspecial ==0">
					<el-upload action="#" ref="upload" list-type="picture-card" :auto-upload="false"
						:on-change="changList" :limit="9" :multiple="true">
						<i slot="default" class="el-icon-plus"></i>
						<div slot="file" slot-scope="{file}">
							<img class="el-upload-list__item-thumbnail" :src="file.url" alt="">
							<span class="el-upload-list__item-actions">
								<span class="el-upload-list__item-preview" @click="handlePictureCardPreview(file)">
									<i class="el-icon-zoom-in"></i>
								</span>
								<span v-if="!disabled" class="el-upload-list__item-delete" @click="handleRemove(file)">
									<i class="el-icon-delete"></i>
								</span>
							</span>
						</div>
					</el-upload>
					<!-- <el-button type="primary" @click="pictureUploadUrl">上传</el-button> -->
				</el-form-item>
				<el-form-item label="上传视频" prop="contenturl"
					v-if="createContentForm.isspecial ==3 || createContentForm.isspecial ==4">
					<el-upload action="#" ref="upload_vedio" list-type="picture-card" :auto-upload="false"
						:on-change="changList" :limit="1">
						<i slot="default" class="el-icon-plus"></i>
						<div slot="file" slot-scope="{file}">
							<!-- <img class="el-upload-list__item-thumbnail" :src="file.url" alt=""> -->
							<video :src="file.url" object-fit="cover"> </video>
							<span class="el-upload-list__item-actions">
								<span class="el-upload-list__item-preview" @click="handleMediaCardPreview(file)">
									<i class="el-icon-zoom-in"></i>
								</span>
								<span v-if="!disabled" class="el-upload-list__item-delete" @click="handleRemove3(file)">
									<i class="el-icon-delete"></i>
								</span>
							</span>
						</div>
					</el-upload>
					<!-- <el-button type="primary" @click="pictureUploadUrl">上传</el-button> -->
				</el-form-item>
				<el-form-item label="联系方式" prop="place">
					<el-input v-model="createContentForm.place" placeholder="请输入联系方式" />
				</el-form-item>
				<el-form-item label="可见范围" prop="visiblerange">
					<el-select v-model="createContentForm.visiblerange" placeholder="请选择可见范围">
						<el-option v-for="dict in dict.type.bbs_content_visibleRange" :key="dict.value"
							:label="dict.label" :value="dict.value">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="状态" prop="contentstate">
					<el-select v-model="createContentForm.contentstate" placeholder="请选择帖子状态">
						<el-option v-for="dict in dict.type.bbs_content_state" :key="dict.value" :label="dict.label"
							:value="dict.value">
						</el-option>
					</el-select>
				</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button type="primary" @click="submitCreateContent">确 定</el-button>
				<el-button @click="cancel">取 消</el-button>
			</div>
		</el-dialog>
		<el-dialog :visible.sync="dialogMediaVisible">
			<img v-if='createContentForm.isspecial ==1 || createContentForm.isspecial ==0' width="100%"
				:src="dialogMediaUrl" alt="">
			<video v-if='createContentForm.isspecial ==3 || createContentForm.isspecial ==4' width="100%"
				:src="dialogMediaUrl"></video>
		</el-dialog>
		<!-- 添加校园信息帖对话框 -->
		<el-dialog v-loading="loading" :title="title" :visible.sync="createSchoolInfoOpen" width="60%" append-to-body>
			<el-form ref="createSchoolInfoForm" :model="createSchoolInfoForm" :rules="rules" label-width="150px">
				<!-- <el-form-item label="发帖人" prop="userid">
					<el-select v-model="createContentForm.userid" placeholder="请选择发帖人" clearable>
						<el-option v-for="user in robotList" :key="user.userid" :label="user.nickname"
							:value="user.userid">
						</el-option>
					</el-select>
				</el-form-item> -->
				<el-form-item label="发帖人ID" prop="userid">
					<el-input v-model="createSchoolInfoForm.userId" placeholder="请输入发帖人ID" />
					<!-- <div > 备注：发帖人ID不需要改动，若需要切换为测试数据库：3f26a21220ae4a3a80f1a19cc5ed8e62</div> -->
				</el-form-item>
				<el-form-item label="帖子所属学校" prop="schoolid">
					<el-select v-model="createSchoolInfoForm.schoolId" placeholder="请选择学校" clearable>
						<el-option v-for="school in currentschools" :key="school.value" :label="school.name"
							:value="school.schoolid">
						</el-option>
					</el-select>
				</el-form-item>
				<!-- <el-form-item label="板块" prop="plateid">
					<el-select v-model="createSchoolInfoForm.plateId" placeholder="请选择板块" clearable>
						<el-option v-for="plate in currentPlateList" :key="plate.plateid" :label="plate.name"
							:value="plate.plateid">
						</el-option>
					</el-select>
				</el-form-item> -->
				<el-form-item label="标题名" prop="title">
					<el-input v-model="createSchoolInfoForm.title" placeholder="请输入标题名" />
				</el-form-item>
				<el-form-item label="帖子类型" prop="contenttype">
					<!-- <el-input v-model="createContentForm.contenttype" placeholder="请输入帖子类型。0：普通贴；3:匿名贴；" /> -->
					<el-select v-model="createSchoolInfoForm.contentType" placeholder="请选择帖子类型">
						<el-option v-for="contentType in typeList" :key="contentType.value" :label="contentType.name"
							:value="contentType.value">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="可见范围" prop="visiblerange">
					<el-select v-model="createSchoolInfoForm.visibleRange" placeholder="请选择可见范围">
						<el-option v-for="dict in dict.type.bbs_content_visibleRange" :key="dict.value"
							:label="dict.label" :value="dict.value">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="校园信息列表" prop="schoolInfo">
					<el-button type="primary" @click="addOneSchoolInfo">新 增</el-button>
				</el-form-item>
				<div v-for="(schoolInfo, index) in createSchoolInfoForm.schoolInfos" :key="index" class="schoolInfo">
					<div style="width: 90%; margin-right: 30px; padding-top: 20px; padding-bottom: 20px; ">
						<el-form-item label="信息内容" prop="intro">
							<el-input type="textarea" v-model="schoolInfo.intro" placeholder="请输入信息内容" />
						</el-form-item>
						<el-form-item label="信息图片" prop="imagUrls">
							<el-upload class="upload-demo" action="#" :ref="schoolInfo.key" list-type="picture"
								:http-request="uploadRequest" :limit="1" :before-upload="compressImage3">
								<el-button size="small" type="primary" @click="getCurrentIndex(index)">
									点击上传
								</el-button>
							</el-upload>
						</el-form-item>
						<el-form-item label="联系方式" prop="linkman">
							<el-input v-model="schoolInfo.linkman" placeholder="请输入联系方式" />
						</el-form-item>
					</div>
					<el-button type="danger" circle icon="el-icon-delete" @click.prevent="removeSchoolinfo(index)"
						style="height: 50px; width: 50px;">
					</el-button>
				</div>

			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button type="primary" @click="submitCreateSchoolInfo">确 定</el-button>
				<el-button @click="cancel">取 消</el-button>
			</div>
		</el-dialog>
		<el-dialog :visible.sync="dialogVisible">
			<img width="100%" :src="dialogImageUrl" alt="">
		</el-dialog>
		<!-- 修改内容帖对话框 -->
		<el-dialog :title="title" :visible.sync="open" width="500px" height="500px" append-to-body @close="cancel">
			<el-form ref="form" :model="form" :rules="rules" label-width="80px">
				<!-- 				<el-form-item label="是否通过" prop="ischecked">
					<el-select v-model="form.ischecked" placeholder="请选择">
						<el-option v-for="item in checkStateSet" :key="item.value" :label="item.label"
							:value="item.value">
						</el-option>
					</el-select>
				</el-form-item> -->
				<!-- 				<el-form-item label="标题" prop="title">
					<el-input v-model="form.title" placeholder="请输入帖子标题" />
				</el-form-item> -->
				<el-form-item label="阅读人数" prop="realreadnum">
					<el-input v-model="form.realreadnum" placeholder="请输入数量" type="number" />
				</el-form-item>
				<el-form-item label="可见范围" prop="visiblerange">
					<el-select v-model="form.visiblerange" placeholder="请选择可见范围">
						<el-option v-for="dict in dict.type.bbs_content_visibleRange" :key="dict.value"
							:label="dict.label" :value="dict.value">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="状态" prop="contentstate">
					<el-select v-model="form.contentstate" placeholder="请选择帖子状态">
						<el-option v-for="dict in dict.type.bbs_content_state" :key="dict.value" :label="dict.label"
							:value="dict.value">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="创建时间" prop="createtime">
					<el-date-picker clearable v-model="form.createtime" type="datetime" placeholder="请选择创建时间">
					</el-date-picker>
				</el-form-item>
				<el-form-item label="不可评论" prop="nocomment">
					<el-select v-model="form.nocomment" placeholder="是否不可评论">
						<el-option v-for="dict in dict.type.bbs_true_or_false" :key="dict.value" :label="dict.label"
							:value="dict.value">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="仅校友可见" prop="alumnionly">
					<el-select v-model="form.alumnionly" placeholder="是否仅校友可见">
						<el-option v-for="dict in dict.type.bbs_true_or_false" :key="dict.value" :label="dict.label"
							:value="dict.value">
						</el-option>
					</el-select>
				</el-form-item>
				<!-- <el-form-item v-if="form.contenttype==2" label="原字段" prop="contenturl">
					<el-input readonly v-model="form.contenturl" />
				</el-form-item> -->
				<el-form-item v-if="form.contenttype==2 ||form.isspecial==3 ||form.isspecial==4" label="视频地址" prop="">
					<!-- <el-input readonly v-model="videoAddress" /> -->
					<el-link type="primary" :href="videoAddress" target="_blank">{{videoAddress}}</el-link>
				</el-form-item>
				<el-form-item v-if="form.contenttype==2 ||form.isspecial==3 ||form.isspecial==4" label="视频号" prop="">
					<el-input v-model="videoId" placeholder="请输入视频号" />
				</el-form-item>
				<el-form-item
					v-if="form.contentstate!=contentOldForm.contentstate || form.visiblerange !=contentOldForm.visiblerange || form.nocomment !=contentOldForm.nocomment || form.alumnionly !=contentOldForm.alumnionly "
					label="操作记录备注" prop="note">
					<el-input v-model="operatinForm.note" placeholder="请输入操作记录备注" />
				</el-form-item>

				<userUpdateForm v-if="showUserUpdateForm" ref="userUpdateForm" :currentSchoolId="targetRow.schoolid"
					:currentUserId="targetRow.userid"></userUpdateForm>

			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button type="primary" @click="submitForm">确 定</el-button>
				<el-button @click="cancel">取 消</el-button>
			</div>
		</el-dialog>
	
		<!-- 添加论坛用户对话框 -->
		<el-dialog v-loading="loading" :title="title" :visible.sync="createUserOpen" width="500px" append-to-body>
			<el-form ref="createUserForm" :model="createUserForm" :rules="rules" label-width="80px">
				<el-form-item label="昵称" prop="nickname">
					<el-input v-model="createUserForm.nickname" placeholder="请输入昵称" />
				</el-form-item>
				<el-form-item label="头像地址" prop="headimgurl">
					<el-upload action="#" ref="upload1" list-type="picture-card" :auto-upload="false"
						:on-change="changList" :limit="1" :before-upload="compressImage">
						<i slot=" default" class="el-icon-plus"></i>
						<div slot="file" slot-scope="{file}">
							<img class="el-upload-list__item-thumbnail" :src="file.url" alt="">
							<span class="el-upload-list__item-actions">
								<span class="el-upload-list__item-preview" @click="handlePictureCardPreview(file)">
									<i class="el-icon-zoom-in"></i>
								</span>
								<span v-if="!disabled" class="el-upload-list__item-delete" @click="handleRemove1(file)">
									<i class="el-icon-delete"></i>
								</span>
							</span>
						</div>
					</el-upload>
				</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button type="primary" @click="submitCreateUser">确 定</el-button>
				<el-button @click="cancel">取 消</el-button>
			</div>
		</el-dialog>

		<el-dialog title="帖子详情与评论" :visible.sync="contentDetailState" width="80%">
			<contentDetail v-if="contentDetailState" ref="contentDetail" :currentContentId="currentContentId"
				:robotList="robotList" @closeContentDetail="contentDetailState = false"></contentDetail>
		</el-dialog>

		<el-dialog title="帖子详情与评论" :visible.sync="contentVisible" width="80%">
			<h3>帖子详情</h3>
			<h4>Id：{{currentSelectPlate.contentid}}</h4>
			<h4>标题：{{currentSelectPlate.title}}</h4>
			<h4>内容：</h4>
			<h4 class="post-text" style="white-space: pre-line; ">{{currentSelectPlate.contenttext}}</h4>
			<h4>联系方式：{{currentSelectPlate.place}}</h4>
			<div v-if="currentSelectPlate.contenttype!=2 &&currentSelectPlate.isspecial!=3 &&currentSelectPlate.isspecial!=4"
				style="display: flex; margin-bottom: 20px;">
				<div style="margin-left: 10px;" v-for="mediaItem in currentSelectPlate.contenturl">
					<el-image style="width: 100px; height: 100px" :src="mediaItem" fit="contain"
						:preview-src-list="currentSelectPlate.contenturl"></el-image>
				</div>
			</div>
			<!--   formatDateTime   -->
			<div style="display: flex;">
				<div>创建时间：{{formatDateTime(currentSelectPlate.createtime)}}</div>
				<div style="margin-left: 100px;">更新时间：{{formatDateTime(currentSelectPlate.updatetime)}}</div>
				<div style="margin-left: 100px;">发帖地点：{{currentSelectPlate.place}}</div>
			</div>
			<div style="display:flex">
				<el-badge :value="currentSelectPlate.commentnum" class="item">
					<el-button size="small" icon="el-icon-chat-dot-square">评论数</el-button>
				</el-badge>
				<el-badge :value="currentSelectPlate.upnum" class="item">
					<el-button size="small" icon="el-icon-caret-top">
						点赞数</el-button>
				</el-badge>
				<el-badge :value="currentSelectPlate.upnum" class="item">
					<el-button size="small" icon="el-icon-caret-bottom">点踩数</el-button>
				</el-badge>
				<el-badge :value="currentSelectPlate.forwardnum" class="item">
					<el-button size="small" icon="el-icon-share">转发数</el-button>
				</el-badge>
				<el-badge :value="currentSelectPlate.realreadnum" class="item">
					<el-button size="small" icon="el-icon-document">阅读人数</el-button>
				</el-badge>
				<el-badge :value="currentSelectPlate.readnum" class="item">
					<el-button size="small" icon="el-icon-document">阅读次数</el-button>
				</el-badge>
				<el-badge :value="currentSelectPlate.informnum" class="item">
					<el-button size="small" icon="el-icon-error">举报数</el-button>
				</el-badge>
			</div>
			<hr>
			<div style="margin-top:10px">
				<h3>帖子评论</h3>
				<el-row :gutter="10" class="mb8">
					<el-col :span="1.5">
						<el-button type="primary" plain icon="el-icon-plus" size="mini"
							@click="handleCommentAdd(currentSelectPlate)">新增评论
						</el-button>
					</el-col>
				</el-row>
				<el-table v-loading="loading" :data="mainCommentList" @selection-change="handleSelectionChange"
					:default-expand-all="true">
					<el-table-column label="评论人员昵称" align="center">
						<template slot-scope="scope">
							<el-button size="mini" type="text" @click="toUserPage(scope.row)">{{scope.row.nickname}}
							</el-button>
						</template>
					</el-table-column>
					<el-table-column label="评论内容" align="center" prop="commenttext" />
					<el-table-column label="评论图片" align="center" prop="commenturl">
						<template slot-scope="scope">
							<image-preview :src="scope.row.commenturl" :width="50" :height="50" />
						</template>
					</el-table-column>
					<el-table-column label="回复对象" align="center" prop="replynickname" />
					<el-table-column label="点赞数" align="center" prop="upnum" />
					<!-- 					<el-table-column label="从评论回复对象" align="center" prop="replynickname" /> -->
					<el-table-column label="创建时间" align="center" prop="createtime" width="180">
						<template slot-scope="scope">
							<span>{{ parseTime(scope.row.createtime) }}</span>
						</template>
					</el-table-column>
					<el-table-column label="评论状态" align="center" prop="commentstate">
						<template slot-scope="scope">
							<dict-tag :options="dict.type.bbs_comment_state" :value="scope.row.commentstate" />
						</template>
					</el-table-column>
					<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
						<template slot-scope="scope">
							<el-button size="mini" type="text" icon="el-icon-edit" @click="handleCommentAdd(scope.row)">
								评论
							</el-button>
							<el-button size="mini" type="text" icon="el-icon-edit" @click="handleComment(scope.row)">修改
							</el-button>
						</template>
					</el-table-column>
					<el-table-column type="expand" style="margin-left: 10px;">
						<template slot-scope="scope">
							<el-table v-loading="loading" :data="scope.row.children" :show-header="false"
								@selection-change="handleSelectionChange" v-if="scope.row.children.length>0">
								<el-table-column label="评论人员昵称" align="center">
									<template slot-scope="scope">
										<el-button size="mini" type="text" @click="toUserPage(scope.row)">
											{{scope.row.nickname}}
										</el-button>
									</template>
								</el-table-column>
								<el-table-column label="评论内容" align="center" prop="commenttext" />
								<el-table-column label="评论图片" align="center" prop="commenturl">
									<template slot-scope="scope">
										<image-preview :src="scope.row.commenturl" :width="50" :height="50" />
									</template>
								</el-table-column>
								<el-table-column label="回复对象" align="center" prop="replynickname" />
								<el-table-column label="点赞数" align="center" prop="upnum" />
								<el-table-column label="创建时间" align="center" prop="createtime" width="180">
									<template slot-scope="scope">
										<span>{{ parseTime(scope.row.createtime) }}</span>
									</template>
								</el-table-column>
								<el-table-column label="评论状态" align="center" prop="commentstate">
									<template slot-scope="scope">
										<dict-tag :options="dict.type.bbs_comment_state"
											:value="scope.row.commentstate" />
									</template>
								</el-table-column>
								<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
									<template slot-scope="scope">
										<el-button size="mini" type="text" icon="el-icon-edit"
											@click="handleCommentAdd(scope.row)">评论
										</el-button>
										<el-button size="mini" type="text" icon="el-icon-edit"
											@click="handleComment(scope.row)">修改
										</el-button>
									</template>
								</el-table-column>
							</el-table>
						</template>
					</el-table-column>
				</el-table>
			</div>
			<!--渲染评论-->
			<span slot="footer" class="dialog-footer">
				<el-button @click="contentVisible = false">取 消</el-button>
				<el-button type="primary" @click="contentVisible = false">确 定</el-button>
			</span>
		</el-dialog>
		<!--新建评论modal-->
		<el-dialog :title="title" :visible.sync="createCommentOpen" width="500px" append-to-body>
			<el-form ref="createCommentForm" :model="createCommentForm" :rules="rules" label-width="80px">
				<el-form-item label="评论者" prop="userid">
					<el-select v-model="createCommentForm.userid" placeholder="请选择发帖人" clearable>
						<el-option v-for="user in robotList" :key="user.userid" :label="user.nickname"
							:value="user.userid">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="评论内容" prop="commenttext">
					<el-input type="textarea" v-model="createCommentForm.commenttext" placeholder="请输入评论内容" />
				</el-form-item>
				<!-- <el-form-item label="评论的图片，以逗号分割的形式存储" prop="commenturl">
		          <el-input v-model="createCommentForm.commenturl" type="textarea" placeholder="请输入内容" />
		        </el-form-item> -->
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button type="primary" @click="submitCreateComment">确 定</el-button>
				<el-button @click="cancel">取 消</el-button>
			</div>
		</el-dialog>
		<!--修改评论状态-->
		<el-dialog :title="title" :visible.sync="commentOpen" width="500px" append-to-body @close="cancelEditComment">
			<div>
				<el-form ref="commentForm" :model="commentForm" :rules="commentRules" label-width="80px">
					<el-form-item label="评论状态" prop="commentstate">
						<el-select v-model="commentForm.commentstate" placeholder="请选择状态">
							<el-option v-for="dict in dict.type.bbs_comment_state" :key="dict.value" :label="dict.label"
								:value="dict.value">
							</el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="创建时间" prop="createtime">
						<el-date-picker clearable v-model="commentForm.createtime" type="datetime"
							placeholder="请选择创建时间">
						</el-date-picker>
					</el-form-item>
					<el-form-item v-if="commentForm.commentstate!=commentOldForm.commentstate" label="操作记录备注"
						prop="note">
						<el-input v-model="operatinForm.note" placeholder="请输入操作记录备注" />
					</el-form-item>
				</el-form>
				<userUpdateForm v-if="showUserUpdateForm" ref="userUpdateFormComment" :currentUserId="targetRow.userid"
					:currentSchoolId="targetSchoolId"></userUpdateForm>

			</div>
			<div slot="footer" class="dialog-footer">
				<el-button type="primary" @click="submitCommentForm">确 定</el-button>
				<el-button @click="cancelEditComment">取 消</el-button>
			</div>
		</el-dialog>

	</div>
</template>

<script>
	const OSS = require('ali-oss')
	import {
		listContent,
		getContent,
		delContent,
		addContent,
		updateContent,
		listByTreeContent,
		listContentVo,
		createSchoolInfos,
		deletePostInRedisById,
		deleteTopPostInRedis,
		deletePostListInRedis,
		updatePostInfoInRedisById,
		listAllSchoolContentVo,
		getHotPostList
	} from "@/api/bbs_content/content";
	import {
		listComment,
		getComment,
		delComment,
		addComment,
		updateComment,
		getCommentById,
		updateCommentState,
		getCommentVoById,
		deleteCommentListInRedis,
		getHotComment
	} from "@/api/bbs_comment/comment";
	import {
		getAllSchools,
		addBbs_user,
		listBbs_robot,
		listBbs_user,
		updateBbs_user,
	} from "@/api/bbs_user/bbs_user";
	import {
		listPlateCate,
		listPlateTree,
		listPlate
	} from "@/api/bbs_plate/plate";
	import {
		getDicts
	} from "@/api/system/dict/data";
	import {
		beforeUpload1,
		beforeUpload2,
		beforeUpload3,
	} from '@/utils/compress';
	import {
		schoolInfo
	} from '@/utils/currentSchool';
	import {
		addBbs_operation_record,
	} from "@/api/bbs_operation_record/bbs_operation_record";
	// import {
	// 	mapState,
	// } from 'vuex'
	import schoolInfoList from '../../utils/schoolInfo.js'
	import userUpdateForm from "../components/userInfo/updateForm.vue"
	import contentDetail from "../components/contentDetail/contentDetail.vue"
	import html2canvas from "html2canvas";
	export default {
		name: "Content",
		dicts: ['bbs_content_state', 'bbs_content_type', 'bbs_content_visibleRange',
			'bbs_comment_state', 'bbs_new_content_type', 'bbs_content_special',
			'bbs_true_or_false', 'bbs_user_type', 'bbs_user_state'
		],
		components: {
			userUpdateForm,
			contentDetail
		},
		// computed: {
		// 	...mapState({
		// 	  currentSchool: state => state.user.currentSchool,
		// 	  })
		// },
		data() {
			return {
				// 遮罩层
				loading: true,
				// 选中数组
				ids: [],
				// 非单个禁用
				single: true,
				// 非多个禁用
				multiple: true,
				// 显示搜索条件
				showSearch: true,
				// 总条数
				total: 0,
				// 内容帖表格数据
				contentList: [],
				// 弹出层标题
				title: "",
				// 是否显示弹出层
				open: false,
				// 是否显示创建帖子弹出层
				createContentOpen: false,
				// 是否显示创建校园信息贴弹出层
				createSchoolInfoOpen: false,
				// 是否显示机器人创建弹出层
				createUserOpen: false,
				// 是否显示评论创建弹出层
				createCommentOpen: false,
				// 是否显示评论弹出层
				commentOpen: false,
				// 查询参数
				queryParams: {
					pageNum: 1,
					pageSize: 10,
					userid: null,
					plateid: null,
					// schoolid: schoolInfo.schoolid,
					schoolid: null,
					title: null,
					contenttext: null,
					contenturl: null,
					place: null,
					upnum: null,
					downnum: null,
					commentnum: null,
					forwardnum: null,
					realreadnum: null,
					readnum: null,
					informnum: null,
					isspecial: null,
					visiblerange: null,
					contentstate: null,
					contenttype: null,
					nocomment: null,
					voteid: null,
					createtime: null,
					updatetime: null,
					orderByColumn: 'createtime',
					contentid: null,
					alumnionly: null
				},
				// 表单参数
				form: {},
				// 表单校验
				rules: {},
				commentRules: {

				},
				//控制帖子详情打开关闭的变量
				contentVisible: false,
				currentSelectPlate: "",
				//可选项的变量
				checkStateSet: [{
					value: 0,
					label: '未审核'
				}, {
					value: 1,
					label: '审核通过'
				}, {
					value: 2,
					label: '审核不通过'
				}],
				ismain: [{
						value: 0,
						label: '是'
					},
					{
						value: 1,
						label: '否'
					}
				],
				stateSelectSet: [{
						value: 0,
						label: '正常'
					}, {
						value: 1,
						label: '折叠展示'
					}, {
						value: 2,
						label: '置顶'
					}, {
						value: 3,
						label: '需要审核'
					}, {
						value: 4,
						label: '已下架'
					},
					{
						value: 5,
						label: '举报'
					}
				],
				viewState: [{
						value: 0,
						label: '校内'
					},
					{
						value: 1,
						label: '板块内'
					}, {
						value: 2,
						label: '校内外'
					}
				],
				//【评论列表
				commentList: null,
				//主评论列表
				mainCommentList: [],
				//子评论列表
				replyCommentList: [],
				//参考树的设计
				root: [{
					name: "校园列表"
				}],
				query: {
					schoolId: "",
					cateId: "",
				},
				plates: [],
				expandNodes: [0],
				props: {
					label: "name",
					children: "zones",
					isLeaf: (data, node) => {
						if (node.level == 2) { //二级级为叶子节点
							return true
						}
					},
				},

				//帖子状态选择集
				contentStateSet: "",

				commentStateSet: "",
				//评论状态
				commentState: "",

				//帖子可视状态
				viewStateSet: "",

				//评论表单
				commentForm: {},

				//树查询结构体
				treeQueryParams: {
					pageNum: 1,
					pageSize: 10,
					schoolId: null,
					plateId: null,
					cateId: null,
				},

				//由于点击cateid时无法获取schoolid，所以需要一个变量来记录
				currentSchoolId: "",

				//创建新帖子
				createContentForm: {
					contentid: null,
					userid: null,
					schoolid: null,
					plateid: null,
					title: null,
					contenttext: null,
					contenturl: null,
					contenttype: null,
					visiblerange: null,
					contentstate: 0,
					createtime: null,
					updatetime: null,
					isspecial: null,
					place: null

				},

				//创建校园信息帖子
				createSchoolInfoForm: {
					// userId: schoolInfo.adminUserId,
					userId: null,
					schoolId: null,
					plateId: null,
					title: null,
					contentText: null,
					contentType: null,
					visibleRange: null,
					isSpecial: null,
					schoolInfos: [],
				},


				//创建新评论
				createCommentForm: {
					userid: null,
					commenttext: null,
					contentid: null,
					ismain: null,
					isreply: null,
					replycommentid: null,
					replyuserId: null,


				},

				//创建新机器人
				createUserForm: {
					userid: null,
					nickname: null,
					headimgurl: null,
					openid: null,
					createtime: null,
					updatetime: null,
					schoolid: null,
				},
				// 机器人查询参数
				robotQueryParams: {
					pageNum: 1,
					pageSize: 100,
					// schoolid: schoolInfo.schoolid,
					schoolid: null,
					userid: null,
					inviter: null,
					// openId:null,
					phone: null,
					// sex: null,
					// email: null,
					// idcardurl: null,
					// nickname: null,
					// headimgurl: null,
					// platenum: null,
					usertype: null,
					userstate: null,
					orderByColumn: 'updatetime',
					// lastip: null,
					// introduction: null,
				},
				//图片上传相关
				dialogImageUrl: '',
				dialogVisible: false,
				dialogMediaUrl: '',
				dialogMediaVisible: false,
				disabled: false,
				picFileList: [],
				currentIndex: '',


				//学校列表
				currentschools: [],
				schools: [],
				//当前学校板块列表
				currentPlateList: [],
				typeList: [{
						name: "分享吐槽",
						value: 5
					},
					{
						name: "求助",
						value: 6
					},
					{
						name: "组队交友",
						value: 7
					}, {
						name: "二手兼职",
						value: 8
					},

				],
				specialList: [{
						name: "普通贴",
						value: 0
					},
					{
						name: "匿名贴",
						value: 1
					},
					{
						name: "视频贴",
						value: 3
					},
					{
						name: "匿名视频贴",
						value: 4
					},
				],
				currentSpecial: 0,
				robotList: [],
				videoAddress: '',
				videoId: '',
				//编辑群发配置
				bbsBatchConfig: {
					configJson: {
						noteLink: '',
						noteText: '',
						batchNumMax: '',
						batchNumMin: ''
					}
				},
				
				dailyConfig: {
					configJson: {
						hotStandardNum: '',
					}
				},
				otherConfigVisible: false,
				//群发配置列表相关
				bbsBatchConfigList:[],
				batchConfigVisible: false,
				//操作记录有关
				contentOldForm: {},
				commentOldForm: {},
				operatinForm: {
					// id: null,
					schoolId: null,
					recordState: 1,
					operator: null,
					targetKind: null,
					targetId: null,
					changeInfo: null,
					note: null,
					// operateTime: null,
					// bannedTime: null,
					// createTime: null,
					// updateTime: null
				},
				targetRow: {},
				showUserUpdateForm: false,
				//帖子详情组件
				contentDetailState: false,
				currentContentId: '',
				currentInAllSchool: false,
				targetSchoolId: null,
				checkConfigVisible: false,
				//配置
				checkConfig: {
					configJson: {
						checkState: -1,
						AICheckState: -1,
						AIIdList: [],
						AIFailMode: -1,
						sensitiveWordList: '',
						sensitiveWordCheckState: -1,
					}
				},
				trueOrFalse: [{
						label: "是",
						vlaue: 1
					},
					{
						label: "否",
						vlaue: 0
					}
				],
				showPoster: false,
				currentPoster: {},
				currentPosterComment: {},
				wxQRCode: '',
				hotPostList: [],
				showHotPostPoster: false,
				//wx联系人
				basicConfig:{},
				basicConfigForm:{},
				oldBasicConfigForm:{},
				basicConfigList:[]


			};
		},
		created() {
			// this.getList();
			console.log('当前学校', this.$store.state.user.currentSchool)
			this.currentschools = [this.$store.state.user.currentSchool]
			console.log('当前学校列表', this.currentschools)
			this.queryParams.schoolid = this.$store.state.user.currentSchool.schoolid
			if (!this.$route.query.userId && !this.$route.query.contentId) {
				// console.log('触发')
				this.getContentVoList();
			}
			this.getDict();
			this.robotQueryParams.schoolid = this.$store.state.user.currentSchool.schoolid
		},
		computed: {
		    posterStyle() {
		      if (this.currentschools.length > 0 && this.currentschools[0].schoolid < 10000) {
		        return {
		          backgroundImage: 'linear-gradient(180deg, #5BFFF5, #20b9f0)',
		        };
		      } else {
		        return {
		          backgroundImage: 'linear-gradient(180deg, #D9FF92, #BBFF92)',
		        };
		      }
		    },
		  },
		activated: function() {
			if (this.$route.query.userId) {
				console.log('参数', this.$route.query.userId)
				this.queryParams.userid = this.$route.query.userId
				this.getContentVoList();
				// this.queryParams.userid = null
			}
			if (this.$route.query.contentId) {
				console.log('参数', this.$route.query)
				this.queryParams.contentid = this.$route.query.contentId
				if (this.$route.query.schoolId) {
					this.currentschools = [schoolInfoList.selectOneSchoolInfo(this.$route.query.schoolId)]
					this.$store.commit('SET_currentSchool', schoolInfoList.selectOneSchoolInfo(this.$route.query
						.schoolId))
				}
				this.getContentVoList();
				// this.queryParams.userid = null
			}
			if (!this.$route.query.userId && !this.$route.query.contentId) {
				// console.log('无参数')
				this.getContentVoList();
			}

		},
		beforeRouteLeave(to, from, next) {
			console.log('离开页面时调用的方法');
			// 清空条件
			this.queryParams.userid = null;
			this.queryParams.contentid = null;
			this.queryParams.title = null;
			this.queryParams.contenttext = null;
			this.queryParams.contenttype = null;
			this.queryParams.isspecial = null;
			this.queryParams.visiblerange = null;
			this.queryParams.contentstate = null;
			this.queryParams.nocomment = null;
			this.queryParams.alumnionly = null;
			// 清除当前页面的路由参数
			// const data =this.$route
			// console.log('当前路由',data)
			if (this.$route.query.userId) {
				delete this.$route.query.userId
			}
			if (this.$route.query.contentId) {
				delete this.$route.query.contentId
			}
			next();
		},
		mounted() {
			this.getSchools();
			// this.getCates();
			// this.getPlateTree();
		},
		watch: {
			'createContentForm.schoolid': {
				handler(newName, oldName) {
					let queryParamsPlate = {
						pageNum: 1,
						pageSize: 10,
						// schoolid: schoolInfo.schoolid,
						schoolid: this.$store.state.user.currentSchool.schoolid,
						orderByColumn: 'createtime',
						cateid: 1,
					}
					queryParamsPlate.schoolid = newName
					console.log(queryParamsPlate)
					this.loading = true;
					listPlate(queryParamsPlate).then((response) => {
						this.currentPlateList = response.rows;
						console.log('学校改变', this.currentPlateList)
						this.loading = false;
						for (var i = 0; i < this.currentPlateList.length; i++) {
							if (this.currentPlateList[i].name == '校园广场') {
								this.createContentForm.plateid = this.currentPlateList[i].plateid;
								break;
							} else {
								continue;
							}
						}
					});
				},
				deep: true,
				immediate: true
			}
		},
		methods: {
			/** 压缩图片 */
			compressImage(file) {
				beforeUpload1(file)
			},
			/** 压缩图片3 */
			compressImage3(file) {
				console.log('进入压缩', file)
				beforeUpload3(file)
			},
			/** 查询内容帖列表 */
			getList() {
				this.loading = true;
				// this.queryParams.schoolid=this.$store.state.user.currentSchool.schoolid
				//this.queryParams this.treeQueryParams
				listContent(this.queryParams).then(response => {
					this.contentList = response.rows;
					this.total = response.total;
					this.loading = false;
				});
			},

			pageGetList() {
				this.loading = true;
				console.log("当前请求页面的限额是", this.treeQueryParams.pageSize);

				console.log("当前请求页面的序号是", this.treeQueryParams.pageNum);
				console.log("treeQueryParams", this.treeQueryParams);
				console.log("---------");


				listByTreeContent(this.treeQueryParams).then(response => {
					this.contentList = response.rows;
					this.total = response.total;
					this.loading = false;
				});
			},
			//页面获取
			pageGetVoList() {
				this.loading = true;
				console.log("当前请求页面的限额是", this.treeQueryParams.pageSize);
				this.queryParams.pageSize = this.treeQueryParams.pageSize
				console.log("当前请求页面的序号是", this.treeQueryParams.pageNum);
				this.queryParams.pageNum = this.treeQueryParams.pageNum
				console.log("---------");
				listContentVo(this.queryParams).then(response => {
					this.contentList = response.rows;
					for (var i = 0; i < this.contentList.length; i++) {
						//兼容旧版特殊类型
						if (this.contentList[i].contenttype == 2) {
							this.contentList[i].isspecial = 3
						} else if (this.contentList[i].contenttype == 3) {
							this.contentList[i].isspecial = 1
						} else if (this.contentList[i].contenttype == 4) {
							this.contentList[i].isspecial = 2
						} else {

						}
						//兼容旧版类型
						if (this.contentList[i].contenttype < 5 && this.contentList[i].contenttype != 1) {
							this.contentList[i].contenttype = 5
						} else {

						}


						if (this.contentList[i].contenturl) {
							this.contentList[i].contenturl = this.contentList[i].contenturl.split(',')
						} else {
							this.contentList[i].contenturl = []
						}
					}
					console.log('内容', this.contentList)
					this.total = response.total;
					this.loading = false;
				});
			},
			//兼容多学校
			pageGetVoList0805() {
				if (typeof this.queryParams.schoolid === 'string' && this.queryParams.schoolid.includes(',')) {
					this.currentInAllSchool = true
					this.queryParams.pageSize = this.treeQueryParams.pageSize
					this.queryParams.pageNum = this.treeQueryParams.pageNum
					this.getAllSchoolContentVoList(this.queryParams.schoolid)
				} else {
					this.currentInAllSchool = false
					this.pageGetVoList();
				}
			},
			//根据id获取其下的所有评论（弃用）
			getComments(id) {
				//获取评论
				getCommentById(id).then(response => {
					this.commentList = response.data;
				})
			},
			//根据id获取其下的所有评论
			getCommentVos(id) {
				this.mainCommentList = [];
				this.replyCommentList = [];
				//获取评论
				getCommentVoById(id).then(response => {
					this.commentList = response.data;
					console.log(this.commentList)
					for (var i = 0; i < response.data.length; i++) {
						if (response.data[i].ismain == 1) {
							this.mainCommentList.push(response.data[i])
						} else {
							this.replyCommentList.push(response.data[i])
						}
					}
					for (var i = 0; i < this.mainCommentList.length; i++) {
						this.mainCommentList[i].children = [];
						for (var j = 0; j < this.replyCommentList.length; j++) {
							if (this.mainCommentList[i].commentid == this.replyCommentList[j].replycommentid) {
								this.mainCommentList[i].children.push(this.replyCommentList[j])
							}
						}
					}
					console.log('主', this.mainCommentList)
					console.log('子', this.replyCommentList)
				})
			},
			// 取消按钮
			cancel() {
				this.open = false;
				this.createContentOpen = false;
				this.createUserOpen = false;
				this.createCommentOpen = false;
				this.createSchoolInfoOpen = false;
				this.showUserUpdateForm = false;
				this.checkConfigVisible = false;
				this.reset();
			},
			// 表单重置
			reset() {
				this.form = {
					contentid: null,
					userid: null,
					plateid: null,
					schoolid: null,
					title: null,
					contenttext: null,
					contenturl: null,
					place: null,
					upnum: null,
					downnum: null,
					commentnum: null,
					forwardnum: null,
					readnum: null,
					informnum: null,
					ischecked: null,
					visiblerange: null,
					contentstate: null,
					contenttype: null,
					voteid: null,
					createtime: null,
					updatetime: null
				};
				this.resetForm("form");
			},
			/** 搜索按钮操作 */
			handleQuery() {
				this.queryParams.pageNum = 1;
				this.treeQueryParams.pageNum = 1;
				if (this.currentInAllSchool) {
					this.getAllSchoolContentVoList(this.queryParams.schoolid)
				} else {
					this.getContentVoList();
				}
			},
			/** 重置按钮操作 */
			resetQuery() {
				this.resetForm("queryForm");
				this.handleQuery();
			},
			// 多选框选中数据
			handleSelectionChange(selection) {
				this.ids = selection.map(item => item.contentid)
				this.single = selection.length !== 1
				this.multiple = !selection.length
			},
			/** 新增按钮操作 */
			handleAdd() {
				this.reset();
				this.open = true;
				this.title = "添加内容帖";
			},
			/** 修改按钮操作 */
			handleUpdate(row) {
				this.videoAddress = '';
				this.videoId = '';
				//给子组件传递userId
				this.showUserUpdateForm = true;
				this.targetRow = row;
				this.reset();
				const contentid = row.contentid || this.ids;
				getContent(contentid).then(response => {
					this.form = response.data;
					//字典需要处理为字符型
					if (this.form.contenturl && (this.form.contenttype == 2 || this.form.isspecial == 3 || this
							.form.isspecial == 4)) {
						let videoArr = this.form.contenturl
						videoArr = videoArr.split(',')
						if (videoArr.length >= 1) {
							console.log("视频贴", videoArr)
							this.videoAddress = videoArr[0]
							console.log("视频贴2", this.videoAddress)
							if (videoArr.length > 1) {
								this.videoId = videoArr[1]
								console.log("视频贴3", this.videoId)
							}
						}
					}
					this.form.contentstate = row.contentstate.toString();
					this.form.visiblerange = row.visiblerange.toString();
					this.form.nocomment = row.nocomment.toString();
					this.form.alumnionly = row.alumnionly.toString();
					//将此时的form复制一份，存起来
					this.contentOldForm = JSON.parse(JSON.stringify(this.form));
					this.operatinForm.note = null;
					//this.form.ischecked = row.ischecked.toString()
				}).then(() => {
					//获取用户信息
					// this.getUserInfo(row)
					this.open = true;
					this.title = "修改内容帖";
				});
			},
			handleComment(row) {
				this.commentReset();
				//给子组件传递userId
				this.showUserUpdateForm = true;
				this.targetRow = row;
				console.log("啊啊", this.targetSchoolId)
				const commentid = row.commentid || this.ids
				getComment(commentid).then(response => {
					this.commentForm = response.data;
					this.commentForm.commentstate = row.commentstate.toString();
					//将此时的form复制一份，存起来
					this.commentOldForm = JSON.parse(JSON.stringify(this.commentForm))
					this.operatinForm.note = null;
					this.commentOpen = true;
					this.title = "修改评论";
				});
			},
			commentReset() {
				this.commentForm = {
					commentid: null,
					userid: null,
					contentid: null,
					replycommentid: null,
					isreply: null,
					replynickname: null,
					ismain: null,
					commenttext: null,
					commenturl: null,
					upnum: null,
					downnum: null,
					informnum: null,
					commentstate: null,
					createtime: null,
					updatetime: null
				};
				this.resetForm("commentForm");
			},
			cancelEditComment() {
				this.showUserUpdateForm = false;
				this.commentOpen = false;
			},
			//这里要填写修改状态的逻辑
			submitCommentForm() {
				let that = this
				this.showUserUpdateForm = false;
				this.$refs["commentForm"].validate(valid => {
					if (valid) {
						if (this.commentForm.commentid != null) {
							//修改用户状态
							let code = that.$refs.userUpdateFormComment.updateUserInfo();
							//未填写禁言时间
							if (code == 0) {
								return
							}
							updateComment(this.commentForm).then(response => {
								this.$modal.msgSuccess("修改成功");
								this.createOperationRecord(3, this.commentOldForm, this.commentForm)
								this.commentOpen = false;
								this.getCommentVos(this.commentForm.contentid);
							}).then(() => {

							});
						} else {
							addComment(this.commentForm).then(response => {
								this.$modal.msgSuccess("新增成功");
								this.commentOpen = false;
								// this.getList();
								this.getCommentVos(this.commentForm.contentid);
							});
						}
					}
				});
				this.commentOpen = false;
			},
			/** 提交按钮 */
			submitForm() {
				// this.form.contenturl = this.form.contenturl + "," + this.videoId
				//帖子redis缓存删除
				console.log(this.form)
				this.handleDelPostInRedis(this.form)
				let videoArr = []
				if (this.form.contenttype == 2 || this.form.isspecial == 3 || this.form.isspecial == 4) {
					videoArr.push(this.videoAddress);
					videoArr.push(this.videoId);
					console.log(this.videoArr)
					if (!this.videoId) {
						this.form.contenturl = this.videoAddress
					} else {
						this.form.contenturl = videoArr.join(',');
					}
				}
				this.$refs["form"].validate(valid => {
					if (valid) {
						if (this.form.contentid != null) {
							updateContent(this.form).then(response => {
								this.$modal.msgSuccess("修改成功");
								this.createOperationRecord(2, this.contentOldForm, this.form)
								//修改用户状态
								// console.log("哈哈哈",this.$refs)
								let code = this.$refs.userUpdateForm.updateUserInfo();
								//未填写禁言时间
								if (code == 0) {
									return
								}
								this.showUserUpdateForm = false;
								this.open = false;
								// this.getContentVoList();
								if (typeof this.queryParams.schoolid === 'string' && this.queryParams
									.schoolid.includes(',')) {
									this.currentInAllSchool = true
									this.getAllSchoolContentVoList(this.queryParams.schoolid)
								} else {
									// console.log("哈哈")
									this.currentInAllSchool = false
									this.getContentVoList();
								}

							});
						} else {
							addContent(this.form).then(response => {
								this.$modal.msgSuccess("新增成功");
								this.open = false;
								// this.getContentVoList();
								if (typeof this.queryParams.schoolid === 'string' && this.queryParams
									.schoolid.includes(',')) {
									this.currentInAllSchool = true
									this.getAllSchoolContentVoList(this.queryParams.schoolid)
								} else {
									this.currentInAllSchool = false
									this.getContentVoList();
								}
							});
						}
					}
				});
			},
			//创建操作记录
			createOperationRecord(targetKind, oldInfo, newInfo) {
				console.log("触发")
				//构建操作记录
				this.operatinForm.schoolId = this.$store.state.user.currentSchool.schoolid;
				this.operatinForm.operator = this.$store.state.user.name;
				this.operatinForm.targetKind = targetKind;
				//操作对象为帖子
				if (targetKind == 2) {
					this.operatinForm.targetId = newInfo.contentid;
				}
				//操作对象为评论
				if (targetKind == 3) {
					this.operatinForm.targetId = newInfo.commentid;
				}
				this.operatinForm.changeInfo = {
					data: {
						oldForm: {},
						newForm: {}
					}
				};
				//获取变更了属性值
				let haveChange = 0;
				for (let key in newInfo) {
					let value = newInfo[key];
					// 在这里对属性进行处理
					// console.log(key + ': ' + typeof newInfo[key]);
					if (typeof newInfo[key] != 'object' && newInfo[key] != oldInfo[key]) {
						haveChange = 1
						this.operatinForm.changeInfo.data.oldForm[key] = oldInfo[key]
						this.operatinForm.changeInfo.data.newForm[key] = newInfo[key]
					}
					if (targetKind == 3 && key == 'contentid') {
						this.operatinForm.changeInfo.data.oldForm[key] = oldInfo[key]
						this.operatinForm.changeInfo.data.newForm[key] = newInfo[key]
					}
				}
				if (haveChange == 1) {
					this.operatinForm.changeInfo = JSON.stringify(this.operatinForm.changeInfo)
					console.log(this.operatinForm)
					addBbs_operation_record(this.operatinForm).then(response => {
						this.$modal.msgSuccess("操作记录新增成功");
					});
				}
			},
			//创建对用户的操作记录
			createUserOperationRecord(targetKind, oldInfo, newInfo) {
				console.log("触发")
				//构建操作记录
				this.operatinUserForm.schoolId = this.$store.state.user.currentSchool.schoolid;
				this.operatinUserForm.operator = this.$store.state.user.name;
				this.operatinUserForm.targetKind = targetKind;
				//操作对象为用户
				if (targetKind == 1) {
					this.operatinUserForm.targetId = newInfo.userid;
				}
				this.operatinUserForm.changeInfo = {
					data: {
						oldForm: {},
						newForm: {}
					}
				};
				//获取变更了属性值
				let haveChange = 0;
				for (let key in newInfo) {
					let value = newInfo[key];
					// 在这里对属性进行处理
					// console.log(key + ': ' + typeof newInfo[key]);
					if (typeof newInfo[key] != 'object' && newInfo[key] != oldInfo[key]) {
						haveChange = 1
						this.operatinUserForm.changeInfo.data.oldForm[key] = oldInfo[key]
						this.operatinUserForm.changeInfo.data.newForm[key] = newInfo[key]
					}
				}
				if (haveChange == 1) {
					//如果存在禁言时间
					if (this.operatinUserForm.bannedTime) {
						this.operatinUserForm.note = this.operatinUserForm.note + " 禁言" + this.operatinUserForm
							.bannedTime * 1 + "天"
						const bannedtime = new Date(new Date().getTime() + this.operatinUserForm.bannedTime * 24 * 60 *
							60 * 1000)
						this.operatinUserForm.bannedTime = this.formatDateTime(bannedtime)
						console.log(this.operatinUserForm.bannedTime)
					}
					this.operatinUserForm.changeInfo = JSON.stringify(this.operatinUserForm.changeInfo)
					console.log(this.operatinUserForm)
					addBbs_operation_record(this.operatinUserForm).then(response => {
						this.$modal.msgSuccess("操作记录新增成功");
					});
				}
			},
			/** 删除按钮操作 */
			handleDelete(row) {
				const contentids = row.contentid || this.ids;
				this.$modal.confirm('是否确认删除内容帖编号为"' + contentids + '"的数据项？').then(function() {
					return delContent(contentids);
				}).then(() => {
					this.getContentVoList();
					this.$modal.msgSuccess("删除成功");
				}).catch(() => {});
			},
			/** 导出按钮操作 */
			handleExport() {
				this.download('bbsAdmin/content/export', {
					...this.queryParams
				}, `content_${new Date().getTime()}.xlsx`)
			},

			handleClose() {
				// alert(111);
				this.commentOpen = false;
			},
			//获取字典的函数
			getDict() {

				getDicts("bbs_content_state").then(response => {
					this.contentStateSet = response.data;
					response.data.forEach(item => {
						item.dictValue = Number(item.dictValue);
					})

				})
				getDicts("bbs_comment_state").then(response => {
					this.commentStateSet = response.data;
					response.data.forEach(item => {
						item.dictValue = Number(item.dictValue);
					})
				})

				//修改一下  viewStateSet
				getDicts("bbs_contentVisuable_state").then(response => {
					this.viewStateSet = response.data;
					response.data.forEach(item => {
						item.dictValue = Number(item.dictValue);
					})
				})
			},

			openModal(data) {
				this.contentVisible = true;
				this.currentSelectPlate = data;
				console.log(this.currentSelectPlate)
				this.getCommentVos(this.currentSelectPlate.contentid);
			},

			openModal2(data) {
				this.currentContentId = data.contentid;
				this.contentDetailState = true;
				this.targetSchoolId = data.schoolid
				console.log("显示详情", this.contentDetailState, data, this.targetSchoolId)

			},

			formatDateTime(date) {
				//date是传入的时间
				let d = new Date(date);
				let month = (d.getMonth() + 1) < 10 ? '0' + (d.getMonth() + 1) : (d.getMonth() + 1);
				let day = d.getDate() < 10 ? '0' + d.getDate() : d.getDate();
				let hours = d.getHours() < 10 ? '0' + d.getHours() : d.getHours();
				let min = d.getMinutes() < 10 ? '0' + d.getMinutes() : d.getMinutes();
				let sec = d.getSeconds() < 10 ? '0' + d.getSeconds() : d.getSeconds();
				let times = d.getFullYear() + '-' + month + '-' + day + ' ' + hours + ':' + min + ":" + sec;
				return times;
			},

			//参考树的方法
			loadNode(node, resolve) {
				if (node.level === 0) {
					return resolve(this.root); //this.schools
				}
				if (node.level === 1) {
					return resolve(this.schools);
				}
				if (node.level === 2) {
					console.log(node)
					return resolve(this.cates);
				}
				if (node.level === 3) {
					this.loading = true;
					console.log("树条件", this.query);
					this.query.cateId = node.data.cateid;
					this.query.schoolId = node.parent.data.schoolid;
					listPlateTree(this.query).then((res) => {
						this.plates = res;
						this.loading = false;
						console.log("树结果", this.plates);
						return resolve(this.plates);
					});
				} else {
					return resolve([]);
				}
			},
			handleClick(item, node, el) {
				// this.resetTreeQueryParams();
				// if (node.level === 4) {
				// 	this.treeQueryParams.schoolId = node.parent.parent.data.schoolid;
				// 	this.treeQueryParams.plateId = node.data.plateId;

				// }
				// if (node.level === 3) {
				// 	this.treeQueryParams.plateId = null;
				// 	this.treeQueryParams.cateId = node.data.cateid;
				// 	this.treeQueryParams.schoolId = node.parent.data.schoolid;
				// }
				// if (node.level === 2) {
				// 	this.treeQueryParams.schoolId = node.data.schoolid;
				// 	this.treeQueryParams.cateId = null;
				// 	this.treeQueryParams.plateId = null;
				// }
				if (node.level === 2) {
					this.queryParams.schoolid = node.data.schoolid;
					this.queryParams.plateid = null;
					this.queryParams.pageNum = 1;
					console.log(this.queryParams)
				}
				listContentVo(this.queryParams).then(response => {
					console.log("查询结果" + response);
					this.contentList = response.rows;
					this.total = response.total;
					this.loading = false;
				})

			},
			resetQueryParams() {
				this.queryParams = {
					pageNum: 1,
					pageSize: 10,
					userid: null,
					plateid: null,
					schoolid: null,
					title: null,
					contenttext: null,
					contenturl: null,
					place: null,
					upnum: null,
					downnum: null,
					commentnum: null,
					forwardnum: null,
					realreadnum: null,
					readnum: null,
					informnum: null,
					ischecked: null,
					visiblerange: null,
					contentstate: null,
					contenttype: null,
					voteid: null,
					createtime: null,
					updatetime: null
				}
			},

			resetTreeQueryParams() {
				this.treeQueryParams = {
					pageNum: 1,
					pageSize: 10,
					schoolId: null,
					plateId: null,
					cateId: null,
				}
			},
			getSchools() {
				getAllSchools().then((response) => {
					this.schools = response.data;
					this.schools = this.schools.map((x) => {
						x["name"] = x["schoolname"];
						return x;
					});
					//全部学校
					if (response.data.length > 1) {
						let schoolObj = {
							schoolid: [],
							schoolname: "全部"
						};
						for (let i = 0; i < response.data.length; i++) {
							schoolObj.schoolid.push(response.data[i].schoolid)
						}
						schoolObj.schoolid = schoolObj.schoolid.join(',');
						this.schools.unshift(schoolObj);
					}
					//模拟点击，展开树节点
					// const els = document.getElementsByClassName('el-tree-node__expand-icon')
					// this.$nextTick(() => {
					// 	els[0].click()
					// })
					// this.getCates()
				});
			},
			getCates() {
				listPlateCate().then((res) => {
					res = res.map((x) => {
						x.name = x.catename;
						return x;
					});
					this.cates = res;
					const els = document.getElementsByClassName('el-tree-node__expand-icon')
					this.$nextTick(() => {
						for (var i = 0; i < this.schools.length; i++) {
							els[i + 1].click()
						}
					})
				});
			},
			getPlateTree() {
				this.loading = true;
				console.log("树条件", this.query);
				listPlateTree(this.query).then((res) => {
					this.plates = res;
					this.loading = false;
					console.log("树结果", this.plates);
				});
			},

			//是否审核状态转换
			isCheckAdapter(state) {
				switch (state) {
					case 0:
						state = "未审核"
						break
					case 1:
						state = "审核通过"
						break
					case 2:
						state = "审核未通过"
						break
				}
				return state;
			},

			commentStateAdapter(state) {
				switch (state) {
					case 0:
						state = "正常"
						break
					case 1:
						state = "折叠展示"
						break
					case 2:
						state = "置顶"
						break
					case 3:
						state = "需要审核"
						break
					case 4:
						state = "已下架"
						break
					case 5:
						state = "举报"
						break
				}
				return state;

			},
			//跳转用户界面
			toUserPage(data) {
				console.log('触发', data)
				this.contentVisible = false
				this.$router.push({
					path: '/bbs_user_school/bbs_user',
					query: {
						id: data.userid
					}
				})
			},
			/** 查询内容帖列表+昵称*/
			getContentVoList() {
				this.loading = true;
				//this.queryParams this.treeQueryParams
				this.queryParams.schoolid = this.$store.state.user.currentSchool.schoolid
				if (!this.queryParams.schoolid) {
					this.$message.error('请选择学校');
					return
				}
				listContentVo(this.queryParams).then(response => {
					this.contentList = response.rows;
					for (var i = 0; i < this.contentList.length; i++) {
						//兼容旧版特殊类型
						if (this.contentList[i].contenttype == 2) {
							this.contentList[i].isspecial = 3
						} else if (this.contentList[i].contenttype == 3) {
							this.contentList[i].isspecial = 1
						} else if (this.contentList[i].contenttype == 4) {
							this.contentList[i].isspecial = 2
						} else {

						}
						//兼容旧版类型
						if (this.contentList[i].contenttype < 5 && this.contentList[i].contenttype != 1) {
							this.contentList[i].contenttype = 5
						} else {

						}

						if (this.contentList[i].contenturl) {
							this.contentList[i].contenturl = this.contentList[i].contenturl.split(',')
							// if (this.contentList[i].contenttype == 2) {
							// 	let videoArr = this.contentList[i].contenturl
							// 	if (videoArr.length > 1) {
							// 		console.log("视频贴", videoArr)
							// 		this.contentList[i].videoAddress = videoArr[0]
							// 		console.log("视频贴2", this.contentList[i].videoAddress)
							// 		this.contentList[i].videoId = videoArr[1]
							// 		console.log("视频贴3", this.contentList[i].videoId)
							// 	}
							// }
						} else {
							this.contentList[i].contenturl = []
						}

					}
					console.log('内容', this.contentList)
					this.total = response.total;
					this.loading = false;
				});
			},
			//图片操作相关
			changList(file, fileList) {
				this.picFileList = fileList
				console.log(this.picFileList)
			},
			changSpecialKind(special) {
				if (this.currentSpecial == 0 || this.currentSpecial == 1) {
					if (special == 1 || special == 0) {
						console.log("不变", special)
						this.currentSpecial = special
					} else {
						this.picFileList = []
						if (this.$refs.upload) {
							this.$refs.upload.clearFiles();
						}
						if (this.$refs.upload_vedio) {
							this.$refs.upload_vedio.clearFiles();
						}
						console.log("变", special, this.picFileList)
						this.currentSpecial = special
					}
				} else {
					if (special == 1 || special == 0) {
						this.picFileList = []
						if (this.$refs.upload) {
							this.$refs.upload.clearFiles();
						}
						if (this.$refs.upload_vedio) {
							this.$refs.upload_vedio.clearFiles();
						}
						console.log("变", special, this.picFileList)
						this.currentSpecial = special
					} else {
						console.log("不变", special)
						this.currentSpecial = special
					}
				}
				console.log(special)
			},
			handleRemove(file) {
				let fileList = this.$refs.upload.uploadFiles;
				let index = fileList.findIndex(fileItem => {
					return fileItem.uid === file.uid
				});
				fileList.splice(index, 1);
				console.log(fileList);
				this.picFileList = fileList
				console.log(this.picFileList)
			},
			handleRemove3(file) {
				let fileList = this.$refs.upload_vedio.uploadFiles;
				let index = fileList.findIndex(fileItem => {
					return fileItem.uid === file.uid
				});
				fileList.splice(index, 1);
				console.log(fileList);
				this.picFileList = fileList
				console.log(this.picFileList)
			},
			handleRemove1(file) {
				let fileList = this.$refs.upload1.uploadFiles;
				let index = fileList.findIndex(fileItem => {
					return fileItem.uid === file.uid
				});
				fileList.splice(index, 1);
				console.log(fileList);
				this.picFileList = fileList
				console.log(this.picFileList)
			},
			handleRemove2(file, key) {
				console.log(key, file, this.$refs[key])
				let fileList = this.$refs[key];
				fileList[0].uploadFiles.splice(0, 1);
				for (var i = 0; i < this.createSchoolInfoForm.schoolInfos.length; i++) {
					if (this.createSchoolInfoForm.schoolInfos[i].key == key) {
						this.createSchoolInfoForm.schoolInfos[i].imgUrls == '';
						break
					}
				}
			},
			handlePictureCardPreview(file) {
				this.dialogImageUrl = file.url;
				this.dialogVisible = true;
			},
			handleMediaCardPreview(file) {
				this.dialogMediaUrl = file.url;
				this.dialogMediaVisible = true;
			},
			//上传配置
			uploadConfig() {
				const client = new OSS({
					// yourRegion填写Bucket所在地域。以华东1（杭州）为例，yourRegion填写为oss-cn-hangzhou。
					region: '',
					// 从STS服务获取的临时访问密钥（AccessKey ID和AccessKey Secret）。
					accessKeyId: '',
					accessKeySecret: '',
					// 填写Bucket名称。
					bucket: ''
				});
				return client
			},
			//图片上传
			async pictureUploadUrl(file) {
				let client = this.uploadConfig()
				var fileName = 'Img_' + new Date().getTime()
				//定义唯一的文件名，打印出来的uid其实就是时间戳
				return new Promise((resolve, reject) => {
					client.put('management_img/contentImg/' + fileName, file.raw).then(
						result => {
							//下面是如果对返回结果再进行处理，根据项目需要，下面是我们自己项目所用的，仅供参考
							// this.createContentForm.contenturl = this.createContentForm.contenturl +','+ result.url
							result.url = result.url.replace('keming-bbs.oss-cn-shanghai.aliyuncs.com',
								'image.tanxiaojian.zone')
							resolve(result.url)
						},
						fail => {
							console.log(fail);
							reject(fail);
						})
				})
			},
			//视频上传
			async vedioUploadUrl(file) {
				console.log(file)
				let client = this.uploadConfig()
				const progress = (p, _checkpoint) => {
					// Object的上传进度。
					console.log(p);
					// 分片上传的断点信息。
					console.log(_checkpoint);
				};
				const options = {
					progress,
					partSize: 1024 * 1024, //设置分片大小
					timeout: 120000, //设置超时时间
				};
				var fileName = 'Vedio_' + new Date().getTime()
				//定义唯一的文件名，打印出来的uid其实就是时间戳
				return new Promise((resolve, reject) => {
					client.multipartUpload('management_img/contentImg/' + fileName, file.raw, options).then(
						result => {
							console.log('上传结果', result);
							//下面是如果对返回结果再进行处理，根据项目需要，下面是我们自己项目所用的，仅供参考
							// this.createContentForm.contenturl = this.createContentForm.contenturl +','+ result.url
							let videoArr = result.res.requestUrls[0].split('?')
							console.log(videoArr)
							resolve(videoArr[0])
						},
						fail => {
							console.log(fail);
							reject(fail);
						})
				})
			},
			//图片上传(校园信息专属：需要填入对应校园信息内)
			uploadRequest(params) {
				let that = this
				console.log("request", params)
				let client = this.uploadConfig()
				var suffix = params.file.name.split('.')
				console.log(suffix)
				var fileName = 'file_' + params.file.uid + '.' + suffix[suffix.length - 1]
				client.put('management_img/contentImg/' + fileName, params.file).then(
					result => {
						console.log('success', result, this.currentIndex);
						console.log(this.createSchoolInfoForm.schoolInfos[this.currentIndex])
						this.createSchoolInfoForm.schoolInfos[this.currentIndex].imgUrls = result.url
					},
					fail => {
						console.log(fail);
					})
			},
			getCurrentIndex(index) {
				this.currentIndex = index
				console.log(this.currentIndex)
			},
			/** 新增robot操作 */
			handleUserAdd() {
				if (this.currentInAllSchool) {
					this.$message.error('请切换单校模式');
					return
				}
				this.resetuserCreateForm();
				this.createUserOpen = true;
				this.title = "添加机器人";
			},
			//重置机器人生成
			resetuserCreateForm() {
				if (this.$refs.upload1) {
					this.$refs.upload1.clearFiles();
				}
				this.createUserForm.nickname = null
				this.picFileList = []
			},
			//提交新建机器人
			async submitCreateUser() {
				this.loading = true;
				if (this.createUserForm.nickname == null || this.createUserForm.nickname == '') {
					this.$message.error('未输入昵称');
					this.loading = false;
					return

				}
				if (this.picFileList.length == 0) {
					this.$message.error('未上传头像');
					this.loading = false;
					return
				}
				this.createUserForm.userid = "user" + new Date().getTime()
				this.createUserForm.openid = "robot_" + new Date().getTime()
				this.createUserForm.createtime = new Date().getTime()
				this.createUserForm.updatetime = new Date().getTime()
				this.createUserForm.phone = '123456'
				this.createUserForm.inviter = this.$store.state.user.name;
				this.createUserForm.schoolid = this.$store.state.user.currentSchool.schoolid
				let img = await beforeUpload1(this.picFileList[0])
				//console.log('压缩图', img)
				this.picFileList[0].raw = img
				this.createUserForm.headimgurl = await this.pictureUploadUrl(this.picFileList[0])
				this.$refs["createUserForm"].validate(valid => {
					if (valid) {
						addBbs_user(this.createUserForm).then(response => {
							this.createUserOpen = false;
							this.$modal.msgSuccess("新增成功");
							this.loading = false;
							this.getRobotList()
						});
					}
				});
			},
			//获取当前用户所创建机器人
			getRobotList() {
				this.loading = true;
				// this.robotQueryParams.schoolid = this.$store.state.user.currentSchool.schoolid
				this.robotQueryParams.inviter = this.$store.state.user.name;
				console.log('用户名', this.robotQueryParams.inviter, this.robotQueryParams.schoolid)
				console.log(this.robotQueryParams)
				listBbs_robot(this.robotQueryParams).then((response) => {
					this.robotList = response.rows;
					console.log(this.robotList);
					this.loading = false;
				});

			},
			/** 新增comment操作 */
			handleCommentAdd(row) {
				this.commentCreateReset();
				if (row.contenttext != null) {
					this.createCommentForm.ismain = 1
					this.createCommentForm.isreply = 0
					this.createCommentForm.contentid = row.contentid


				} else {
					this.createCommentForm.ismain = 0
					this.createCommentForm.contentid = row.contentid
					if (row.ismain == 0) {
						this.createCommentForm.isreply = 1
						this.createCommentForm.replycommentid = row.replycommentid
						this.createCommentForm.replyuserid = row.userid

					} else {
						this.createCommentForm.isreply = 0
						this.createCommentForm.replycommentid = row.commentid
						this.createCommentForm.replyuserid = row.userid
					}
				}
				// if(row)
				this.createCommentOpen = true;

				this.title = "添加评论";
			},
			//重置评论参数
			commentCreateReset() {
				this.createCommentForm.userid = ''
				this.createCommentForm.commenttext = ''
				this.createCommentForm.replycommentid = null
				this.createCommentForm.replyuserid = null
			},
			//新建评论提交
			submitCreateComment() {
				this.loading = true;
				if (this.createCommentForm.commenttext == null || this.createCommentForm.commenttext == '') {
					this.$message.error('未输入评论内容');
					this.loading = false;
					return
				}
				if (this.createCommentForm.userid == null || this.createCommentForm.userid == '') {
					this.$message.error('未选择评论人');
					this.loading = false;
					return
				}
				this.createCommentForm.createtime = new Date().getTime()
				this.createCommentForm.updatetime = new Date().getTime()
				this.$refs["createCommentForm"].validate(valid => {
					if (valid) {
						addComment(this.createCommentForm).then(response => {
							this.$modal.msgSuccess("新增成功");
							this.loading = false;
							this.createCommentOpen = false;
							// this.getComments(this.currentSelectPlate.contentid);
							this.getCommentVos(this.currentSelectPlate.contentid);
						});
					}
				});

			},
			//跳转下载
			toH5(url) {
				window.location.href = 'url'
			},
			/** 新增schoolInfo操作 */
			handleSchoolInfoAdd() {
				//清空表单
				this.createSchoolInfoForm.schoolId = this.currentschools[0].value;
				this.createSchoolInfoForm.plateId = this.currentPlateList[0].plateid;
				this.createSchoolInfoForm.title = null;
				this.createSchoolInfoForm.visibleRange = this.dict.type.bbs_content_visibleRange[0].value;;
				this.createSchoolInfoForm.schoolInfos = [];
				//固定信息

				//测试数据库
				// this.createSchoolInfoForm.userId = '3f26a21220ae4a3a80f1a19cc5ed8e62'
				//正式数据库
				// this.createSchoolInfoForm.userId = '9908733a1b7c4095958693b0d8485b79'

				// this.createSchoolInfoForm.contentType = 4
				this.createSchoolInfoForm.isSpecial = 2
				this.createSchoolInfoForm.contentText =
					"搬运声明：为了方便同学及时获取二手、兼职等相关信息，论坛会于每日定时收集、整理校园内各个渠道所发布的公开信息，若需删除，请联系客服。"
				this.createSchoolInfoOpen = true;
				this.title = "添加信息帖";
			},
			//新增一个校园信息
			addOneSchoolInfo() {
				//校园信息结构
				let time = new Date().getTime()
				let schoolInfoForm = {
					key: 'schoolInfo' + time,
					intro: '',
					imgUrls: '',
					linkman: '',
				};
				this.createSchoolInfoForm.schoolInfos.push(schoolInfoForm)
				console.log(this.createSchoolInfoForm.schoolInfos)
			},
			//删除一个校园信息
			removeSchoolinfo(index) {
				this.createSchoolInfoForm.schoolInfos.splice(index, 1)
			},
			//新建校园信息提交
			submitCreateSchoolInfo() {
				this.loading = true;
				if (this.createSchoolInfoForm.schoolInfos.length == 0) {
					this.$message.error('未输入校园信息');
					this.loading = false;
					return
				}
				if (this.createSchoolInfoForm.visibleRange == null || this.createSchoolInfoForm.visibleRange == '') {
					this.$message.error('未选择可见范围');
					this.loading = false;
					return
				}
				if (this.createSchoolInfoForm.title == null || this.createSchoolInfoForm.title == '') {
					this.$message.error('未输入标题');
					this.loading = false;
					return
				}
				if (this.createSchoolInfoForm.plateId == null || this.createSchoolInfoForm.plateId == '') {
					this.$message.error('未选择板块');
					this.loading = false;
					return
				}
				if (this.createSchoolInfoForm.schoolId == null || this.createSchoolInfoForm.schoolId == '') {
					this.$message.error('未选择学校');
					this.loading = false;
					return
				}
				console.log(this.createSchoolInfoForm)
				let content = {}
				this.createSchoolInfoForm.userId = this.currentSchool.adminUserId
				content = this.createSchoolInfoForm
				createSchoolInfos(content).then(response => {
					this.$modal.msgSuccess("新增成功");
					this.loading = false;
					this.createSchoolInfoOpen = false;
					this.getContentVoList();
				});
			},
			changeSchool(value) {
				console.log("改变", value)
				this.createContentForm.schoolid = value
				this.createUserForm.schoolid = value
				this.robotQueryParams.schoolid = value
				for (var i = 0; i < this.schools.length; i++) {
					if (this.schools[i].schoolid == value) {
						this.schools[i].value = value
						this.currentschools = [this.schools[i]]
					}
				}
				this.getRobotList()
				console.log("当前学校是", this.currentschools)
			},
			changeSchoolNew(value) {
				console.log("改变", value)
				if (typeof value === 'string' && value.includes(',')) {
					this.currentInAllSchool = true
					console.log("数组")
					// this.getAllSchoolList(value);
					this.queryParams.pageNum = 1;
					this.getAllSchoolContentVoList(value)
				} else {
					this.currentInAllSchool = false
					this.createContentForm.schoolid = value
					this.createUserForm.schoolid = value
					this.robotQueryParams.schoolid = value
					this.queryParams.schoolid = value
					this.currentschools = [schoolInfoList.selectOneSchoolInfo(value)]
					this.$store.commit('SET_currentSchool', schoolInfoList.selectOneSchoolInfo(value))
					this.queryParams.pageNum = 1;
					this.getContentVoList();
					console.log("当前学校是", this.currentschools, "store", this.$store.state.user.currentSchool)
				}
			},

			//根据帖子ID删除redis中缓存的某个帖子
			handleDelPostInRedis(row) {
				let delRedisParams = {
					contentId: row.contentid,
				}
				deletePostInRedisById(delRedisParams).then(response => {
					console.log(response)
					if (response) {
						this.$modal.msgSuccess("帖子redis缓存删除成功");
					} else {
						this.$modal.msgError("帖子redis缓存删除失败")
					}
				});
			},
			//删除redis中缓存的置顶帖子
			handleDelTopPostInRedis() {
				let delRedisParams = {
					schoolId: this.$store.state.user.currentSchool.schoolid,
				}
				deleteTopPostInRedis(delRedisParams).then(response => {
					console.log(response)
					if (response) {
						this.$modal.msgSuccess("删除置顶帖缓存成功");
					}
				});
			},
			//删除redis中缓存的首页帖子列表
			handleDelHomePostListInRedis() {
				let delRedisParams = {
					schoolId: this.$store.state.user.currentSchool.schoolid,
				}
				deletePostListInRedis(delRedisParams).then(response => {
					console.log(response)
					if (response) {
						this.$modal.msgSuccess("删除帖子列表缓存成功");
					}
				});
			},
			//删除redis中缓存的评论列表
			handleDelCommentListInRedis() {
				let delRedisParams = {
					schoolId: this.$store.state.user.currentSchool.schoolid,
				}
				deleteCommentListInRedis(delRedisParams).then(response => {
					console.log(response)
					if (response) {
						this.$modal.msgSuccess("删除评论列表缓存成功");
					}
				});
			},
			//删除redis中缓存的置顶帖子
			handleUpdatePostInfoInRedis(row) {
				let delRedisParams = {
					contentId: row.contentid,
				}
				updatePostInfoInRedisById(delRedisParams).then(response => {
					console.log(response)
					if (response) {
						this.$modal.msgSuccess("帖子redis缓存更新成功");
					} else {
						this.$modal.msgError("帖子redis缓存更新失败")
					}
				});
			},
			/** 查询内容帖列表+昵称*/
			getAllSchoolContentVoList(value) {
				this.loading = true;
				//this.queryParams this.treeQueryParams
				let queryParams = JSON.parse(JSON.stringify(this.queryParams))
				queryParams.schoolid = null;
				queryParams.schoolIdStr = value
				listAllSchoolContentVo(queryParams).then(response => {
					this.contentList = response.rows;
					for (var i = 0; i < this.contentList.length; i++) {
						//兼容旧版特殊类型
						if (this.contentList[i].contenttype == 2) {
							this.contentList[i].isspecial = 3
						} else if (this.contentList[i].contenttype == 3) {
							this.contentList[i].isspecial = 1
						} else if (this.contentList[i].contenttype == 4) {
							this.contentList[i].isspecial = 2
						} else {

						}
						//兼容旧版类型
						if (this.contentList[i].contenttype < 5 && this.contentList[i].contenttype != 1) {
							this.contentList[i].contenttype = 5
						} else {

						}

						if (this.contentList[i].contenturl) {
							this.contentList[i].contenturl = this.contentList[i].contenturl.split(',')
							// if (this.contentList[i].contenttype == 2) {
							// 	let videoArr = this.contentList[i].contenturl
							// 	if (videoArr.length > 1) {
							// 		console.log("视频贴", videoArr)
							// 		this.contentList[i].videoAddress = videoArr[0]
							// 		console.log("视频贴2", this.contentList[i].videoAddress)
							// 		this.contentList[i].videoId = videoArr[1]
							// 		console.log("视频贴3", this.contentList[i].videoId)
							// 	}
							// }
						} else {
							this.contentList[i].contenturl = []
						}

					}
					console.log('内容', this.contentList)
					this.total = response.total;
					this.loading = false;
				});
			},
			formatSchoolName(row, column, cellValue) {
				const school = this.schools.find(s => s.schoolid === cellValue);
				return school ? school.schoolname : '';
			},
			isRoleIncludeAdmin() {
				// console.log('呀哈哈',this.$store.state.user)
				let haveAdmin = false
				if (this.$store.state.user.roles && this.$store.state.user.roles.length > 0) {
					for (let i = 0; i < this.$store.state.user.roles.length; i++) {
						if (this.$store.state.user.roles[i].includes('admin')) {
							haveAdmin = true
							console.log(this.$store.state.user.roles[i])
							break
						}
					}
				}
				return haveAdmin
			},
			
		}


	};
</script>
<style>
	.contentImg {

		max-height: 400px;
		max-width: 100%;
		padding: 10px 5px 10px 5px
	}

	.item {

		margin-top: 10px;
		margin-right: 40px;
	}

	.schoolInfo {
		display: flex;
		align-items: center;
		border: 1px solid #000;
		margin-bottom: 10px;
		border-radius: 10px;
	}

	.post-text {
		white-space: pre-wrap;
		word-break: break-all;
		word-wrap: break-word;
	}

	.title-clamp {
		display: -webkit-box;
		-webkit-box-orient: vertical;
		overflow: hidden;
		text-overflow: ellipsis;
		-webkit-line-clamp: 1;
		/* 标题最多 2 行 */
		line-height: 24px;
		/* 设置行高 */
		/* margin-bottom: 5px; */
		color: #000;
	}

	.title-clamp2 {
		display: -webkit-box;
		-webkit-box-orient: vertical;
		overflow: hidden;
		text-overflow: ellipsis;
		-webkit-line-clamp: 2;
		/* 标题最多 2 行 */
		line-height: 24px;
		/* 设置行高 */
		/* margin-bottom: 5px; */
		color: #000;
	}
</style>